<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<script>
			var num = prompt('请输入金字塔的层数');
			for(var i = 0; i < num; i++) {
				var nbsp = num - i - 1;
				for(var j = 0; j < nbsp; j++) {
					document.write('&nbsp;');
				}
				var a = (i + 1) * 2 - 1;
				for(var k = 0; k < a; k++) {
					document.write('*')
				}
				document.write('<br>');
			}
		</script>
	</body>

</html>